package com.jckl.foodathon.sqlite.services;

import java.util.List;

import com.jckl.foodathon.sqlite.dao.DaoSession;
import com.jckl.foodathon.sqlite.dao.TB_BrandDao;
import com.jckl.foodathon.sqlite.model.TB_Brand;


public class BrandRepository {
	
	private static TB_BrandDao getBrandDao(DaoSession session) {
		return session.getTB_BrandDao();
    }
	
	public static void insertOrUpdate(DaoSession session, TB_Brand brand){
		getBrandDao(session).insertOrReplace(brand);
	}
	
	public static TB_Brand getBrandForId(DaoSession session, long id){
		return getBrandDao(session).load(id);
	}
	
	public static List<TB_Brand> getAllBrands(DaoSession session){
		return getBrandDao(session).loadAll();
	}
	
	public static void clearBrands(DaoSession session){
		getBrandDao(session).deleteAll();
	}
	
	public static void deleteBrandWithId(DaoSession session, long id){
		getBrandDao(session).delete(getBrandForId(session, id));
	}

}
